<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="button" value="获取元素" @click="getElement" ref="mybtn">
        <h3 ref="myh3">哈哈哈哈哈哈</h3>
        <hr>
        <my-login ref="myLogin"></my-login>
    </div>

    <script>

        var login = {
            template: '<h1>登录组件</h1>',
            data() {
                return {
                    msg: 'son msg'
                }
            },
            methods: {
                show() {
                    console.log('字组件方法')
                }
            }
        }

        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {
                getElement(){
                    // ref 是vue中的引用   这里面是refs表示一个vm实例中可包含多个ref
                    // console.log(this.$refs.myh3.innerText)
                    console.log(this.$refs.myLogin.msg)
                    this.$refs.myLogin.show()
                }
            },
            components: {
                myLogin: login
            }
        }) 
    </script>
</body>
</html>